import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AddEmployeesForm, ContractInquiryQuery, ContractInquiryVO, DownloadListQuery, EmploymentContractForm, InfoEditVo, MemberInfoVo, MerVo, OperVo, SetCardVo, SydVo } from './types';

/**
 * 签约查询
 * @param query
 */
export const contractInquiryList = (query: ContractInquiryQuery): AxiosPromise<ContractInquiryVO[]> => {
  return request({
    url: '/payment/workerBusiness/list',
    method: 'get',
    params: query
  });
};

/**
 * 代理商详情
*/
export const contractInquiryDetail = (id: string | number) => {
  return request({
    url: `/payment/workerBusiness/${id}`,
    method: 'get',
  });
};

/**
 * 授权协议查询
 * @param query
 */
export const authList = (query: ContractInquiryQuery): AxiosPromise<ContractInquiryVO[]> => {
  return request({
    url: '/payment/workerBusiness/authList',
    method: 'get',
    params: query
  });
};

/**
 * 授权协议详情
*/
export const authDetail = (id: string | number) => {
  return request({
    url: `/payment/workerBusiness/getAuth`,
    method: 'get',
    params: {
      id
    }
  });
};

// 用工管理
/**
 * 选择企业
*/
export const listMer = (): AxiosPromise<MerVo[]> => {
  return request({
    url: `/payment/proInfo/listMer`,
    method: 'get',
  });
};


export const selBusType = (): AxiosPromise<MerVo[]> => {
  return request({
    url: `/payment/proInfo/selBusType`,
    method: 'get',
  });
};




/**
 * 选择企业对应的服务商
*/
export const listServ = (id: string | number): AxiosPromise<SydVo[]> => {
  return request({
    url: `/payment/proInfo/listServ`,
    method: 'get',
    params: {
      id
    }
  });
};

/**
 * 选择业务类型
*/
export const selBtByMs = (params: EmploymentContractForm): AxiosPromise<DictDataOption[]> => {
  return request({
    url: `/payment/proInfo/selBtByMs`,
    method: 'get',
    params
  });
};

/**
 * 列表查询
*/
export const listOper = (params: EmploymentContractForm): AxiosPromise<OperVo[]> => {
  return request({
    url: `/payment/workerBusiness/operlist`,
    method: 'get',
    params
  });
};

/**
 * 提交
*/
export const addSelUwb = (params: EmploymentContractForm) => {
  return request({
    url: `/payment/workerBusiness/addSelUwb`,
    method: 'post',
    params
  });
};

/**
 * 全部提交
*/
export const addAllUwb = (params: EmploymentContractForm) => {
  return request({
    url: `/payment/workerBusiness/addAllUwb`,
    method: 'post',
    params
  });
};



/**
 * 添加用工人员
*/
export const addUwb = (data: AddEmployeesForm) => {
  return request({
    url: `/payment/workerBusiness/addUwb`,
    method: 'post',
    data
  });
};

/**
 * 会员信息-详情
*/
export const selWkInfo = (id: string): AxiosPromise<MemberInfoVo> => {
  return request({
    url: `/payment/workerBusiness/selWkInfo`,
    method: 'post',
    params: {
      id
    }
  });
};

/**
 * 会员银行卡列表查询
*/
export const selWkBankList = (workId: string) => {
  return request({
    url: `/payment/workerAccount/bankList`,
    method: 'get',
    params: {
      workId
    }
  });
};

/**
 * 查看结算卡-列表
*/
export const setCard = (workId: string | number): AxiosPromise<SetCardVo[]> => {
  return request({
    url: `/payment/workerAccount/list`,
    method: 'get',
    params: {
      workId
    }
  });
};

/**
 * 查看结算卡-详情
*/
export const setCardDetail = (id: string | number): AxiosPromise<SetCardVo> => {
  return request({
    url: `/payment/workerAccount/${id}`,
    method: 'get',
  });
};

/**
 * 查看结算卡-添加&修改
*/
export const setCardAddAndEdit = (data: SetCardVo, method: string) => {
  return request({
    url: `/payment/workerAccount`,
    method,
    data
  });
};


/**
 * 会员信息-修改查询
*/
export const selUpUwInfo = (id: string | number): AxiosPromise<InfoEditVo> => {
  return request({
    url: `/payment/workerBusiness/selUpUw`,
    method: 'post',
    params: {
      id
    }
  });
};

/**
 * 会员信息-修改提交
*/
export const selUpUwInfoEditSubmit = (params: InfoEditVo) => {
  return request({
    url: `/payment/workerBusiness/upUw`,
    method: 'post',
    params
  });
};

/**
 * 下载身份证(批量)
*/
export const exportMutiCardImg = (workIds: string) => {
  return request({
    url: `payment/workerBusiness/exportMutiCardImg`,
    method: 'post',
    params: {
      workIds
    }
  });
};

/**
 * 下载身份证(单个)
*/
export const exportCardImg = (workId: string | number) => {
  return request({
    url: `payment/workerBusiness/exportCardImg`,
    method: 'post',
    params: {
      workId
    }
  });
};

/**
 * 下载暂存-列表
*/
export const downloadList = (params: DownloadListQuery) => {
  return request({
    url: `payment/downloads/list`,
    method: 'get',
    params
  });
};

/**
 * 下载暂存-删除
*/
export const downloadDel = (ids: string | number) => {
  return request({
    url: `payment/downloads/${ids}`,
    method: 'delete',
  });
};

/**
 * 下载暂存-查看（下载）
*/
export const downloadLook = (ossId: string | number) => {
  return request({
    url: `resource/oss/download/${ossId}`,
    method: 'post',
  });
};


export default {
  contractInquiryList,
  contractInquiryDetail,
  authList,
  authDetail,
  listMer,
  listServ,
  selBtByMs,
  listOper,
  addSelUwb,
  addAllUwb,
  addUwb,
  selWkInfo,
  selWkBankList,
  setCard,
  setCardDetail,
  setCardAddAndEdit,
  selUpUwInfo,
  selUpUwInfoEditSubmit,
  exportMutiCardImg,
  exportCardImg,
  downloadList,
  downloadDel,
  downloadLook,
  selBusType
};
